﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FrbaCommerce.Gestion_de_Preguntas
{
    public partial class FormRespPreg : Form
    {

        
        private int user_id, preg_id;

        public FormRespPreg(int user_id, DataGridViewRow fila)
        {
            InitializeComponent();
            this.user_id = user_id;
            this.preg_id = Convert.ToInt32(fila.Cells["ID"].Value.ToString());
            this.labelTextoPreg.Text = fila.Cells["Descripción"].Value.ToString();
        }

        private void FormRespPreg_Load(object sender, EventArgs e)
        {

        }

        private void botonResponder_Click(object sender, EventArgs e)
        {
            SqlConnection con = Program.obtenerConexion();

            SqlCommand responder = new SqlCommand("UPDATE Monkey_Coders.Preguntas "
            + " SET preg_respuesta_desc = '"+textBoxRespuesta.Text + "'"
            + " WHERE preg_id = " + preg_id, con);

            responder.ExecuteNonQuery();

            MessageBox.Show("Pregunta respondida con éxito!");
            this.Close();
        }
    }
}
